package org.ezplatform.office.questionnaire.dao;
 

import java.util.List;

import org.ezplatform.core.dao.jpa.JpaBaseDao;
import org.ezplatform.office.questionnaire.entity.QuestionnaireTopic;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository("questionnaireTopicDao")
public interface QuestionnaireTopicDao extends JpaBaseDao<QuestionnaireTopic,String>{
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from oa_questionnaire_topic where questionnaire_id =?1")
	int deleteTopicByQuesId(String quesId);
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from oa_questionnaire_topic where questionnaire_id in (?1)")
	int deleteTopicByQuesId(List<String> list);
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from oa_questionnaire_topic where ID = ?1")
	int deleteTopicByTopicId(String topicId);
	
	@Query("Select id from QuestionnaireTopic where questionnaireId = ?1 ")
	List<String> getTopicIdByQeusId(String quesId);
	
	@Query("Select id from QuestionnaireTopic where questionnaireId in (?1) ")
	List<String> getTopicIdByQeusId(List<String> list);
	
	@Query("from QuestionnaireTopic where questionnaireId = ?1 order by createdDate,orderNo")
	List<QuestionnaireTopic> getTopicByQeusId(String quesId);


	@Query("from QuestionnaireTopic where topicType = ?1 and questionnaireId = ?2 and id = ?3")
	List<QuestionnaireTopic> getTopicByTypeAndQuestIdAndId(String type,String quesId,String id);
}
